<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.9.1" />
<title>tronpytool.contract API documentation</title>
<meta name="description" content="" />
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>tronpytool.contract</code></h1>
</header>
<section id="section-intro">
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">#!/usr/bin/env python
# --------------------------------------------------------------------
# Copyright (c) iEXBase. All rights reserved.
# Licensed under the MIT License.
# See License.txt in the project root for license information.
# --------------------------------------------------------------------

import copy
from typing import Tuple, Union

from eth_abi import decode_abi
from eth_utils import (
    function_abi_to_4byte_selector,
    to_hex
)
from hexbytes import HexBytes
from trx_utils import (
    encode_hex,
    is_text,
    deprecated_for,
    combomethod
)
from trx_utils.typing import HexStr

from tronpytool.common.abi import (
    filter_by_type,
    merge_args_and_kwargs,
    abi_to_signature,
    fallback_func_abi_exists,
    check_if_arguments_can_be_encoded,
    map_abi_data, filter_by_name
)
from tronpytool.common.contracts import (
    find_matching_fn_abi,
    encode_abi,
    get_function_info,
    FallbackFn
)
from tronpytool.common.datatypes import PropertyCheckingFactory
from tronpytool.common.encoding import to_4byte_hex
from tronpytool.common.normalizers import (
    normalize_abi,
    normalize_bytecode,
    BASE_RETURN_NORMALIZERS
)
from tronpytool.exceptions import (
    NoABIFunctionsFound,
    MismatchedABI,
    FallbackNotFound
)


class NonExistentFallbackFunction:
    @staticmethod
    def _raise_exception():
        raise FallbackNotFound(&#34;No fallback function was found in the contract ABI.&#34;)

    def __getattr__(self, attr):
        return NonExistentFallbackFunction._raise_exception


class ContractFunction:
    &#34;&#34;&#34;Base class for contract functions&#34;&#34;&#34;
    address = None
    function_identifier = None
    tron = None
    contract_abi = None
    abi = None
    transaction = None
    arguments = None

    def __init__(self, abi=None):
        self.abi = abi
        self.fn_name = type(self).__name__

    def __call__(self, *args, **kwargs):
        clone = copy.copy(self)
        if args is None:
            clone.args = tuple()
        else:
            clone.args = args

        if kwargs is None:
            clone.kwargs = {}
        else:
            clone.kwargs = kwargs
        clone._set_function_info()
        return clone

    def _set_function_info(self):
        if not self.abi:
            self.abi = find_matching_fn_abi(
                self.contract_abi,
                self.function_identifier,
                self.args,
                self.kwargs
            )
        if self.function_identifier is FallbackFn:
            self.selector = encode_hex(b&#39;&#39;)
        elif is_text(self.function_identifier):
            self.selector = encode_hex(function_abi_to_4byte_selector(self.abi))
        else:
            raise TypeError(&#34;Unsupported function identifier&#34;)

        self.arguments = merge_args_and_kwargs(self.abi, self.args, self.kwargs)

    @classmethod
    def factory(cls, class_name, **kwargs):
        return PropertyCheckingFactory(class_name, (cls,), kwargs)(kwargs.get(&#39;abi&#39;))

    def __repr__(self):
        if self.abi:
            _repr = &#39;&lt;Function %s&#39; % abi_to_signature(self.abi)
            if self.arguments is not None:
                _repr += &#39; bound to %r&#39; % (self.arguments,)
            return _repr + &#39;&gt;&#39;
        return &#39;&lt;Function %s&gt;&#39; % self.fn_name


class ContractFunctions:
    &#34;&#34;&#34;
    Class containing contract function objects
    &#34;&#34;&#34;

    def __init__(self, _abi, tron, address=None):
        if _abi:
            self._functions = filter_by_type(&#39;function&#39;, _abi)
            for func in self._functions:
                setattr(self, func[&#39;name&#39;],
                        ContractFunction.factory(
                            func[&#39;name&#39;],
                            tron=tron,
                            contract_abi=_abi,
                            address=address,
                            function_identifier=func[&#39;name&#39;]))
            self.abi = _abi

    def get_abi_by_name(self, func_name: str) -&gt; dict:
        &#34;&#34;&#34;Find the correct function abi for the name&#34;&#34;&#34;
        t = filter_by_name(func_name, self.abi)
        if len(t) &gt; 0:
            return t[0]
        raise NoABIFunctionsFound(
            &#34;The abi for this contract contains no function definitions. &#34;,
            &#34;Are you sure you provided the correct call name from the abi?&#34;
        )

    def print_functions(self):
        &#34;&#34;&#34;only for testing, list all the functions that can be called. &#34;&#34;&#34;
        for func in self._functions:
            if func[&#39;type&#39;] == &#39;function&#39;:
                if func[&#39;stateMutability&#39;] in [&#39;pure&#39;, &#39;view&#39;]:
                    printdebugfunc(&#39;read&#39;, func)
                if func[&#39;stateMutability&#39;] in [&#39;nonpayable&#39;]:
                    printdebugfunc(&#39;write&#39;, func)

            if func[&#39;type&#39;] == &#39;constructor&#39;:
                printdebugfunc(&#39;constructor&#39;, func)
            print(&#34;=====&#34;)
            print(func)

    def __iter__(self):
        if not hasattr(self, &#39;_functions&#39;) or not self._functions:
            return

        for func in self._functions:
            yield func[&#39;name&#39;]

    def __getattr__(self, function_name):
        if &#39;_functions&#39; not in self.__dict__:
            raise NoABIFunctionsFound(
                &#34;The abi for this contract contains no function definitions. &#34;,
                &#34;Are you sure you provided the correct contract abi?&#34;
            )
        elif function_name not in self.__dict__[&#39;_functions&#39;]:
            raise MismatchedABI(
                &#34;The function &#39;{}&#39; was not found in this contract&#39;s abi. &#34;.format(function_name),
                &#34;Are you sure you provided the correct contract abi?&#34;
            )
        else:
            return super().__getattribute__(function_name)

    def __getitem__(self, function_name):
        return getattr(self, function_name)


class Contract:
    # set during class construction
    tron = None

    # instance level properties
    address = None

    # class properties (overridable at instance level)
    abi = None

    bytecode = None
    bytecode_runtime = None

    functions = None
    events = None
    fallback = None

    def __init__(self, address=None):
        &#34;&#34;&#34;Create a new smart contract proxy object.
        :param address: Contract address as 0x hex string
        &#34;&#34;&#34;
        if self.tron is None:
            raise AttributeError(
                &#39;The `Contract` class has not been initialized.  Please use the &#39;
                &#39;`tron.contract` interface to create your contract class.&#39;
            )

        if address:
            self.address = self.tron.address.to_hex(address)

        if not self.address:
            raise TypeError(&#34;The address argument is required to instantiate a contract.&#34;)

        self.functions = ContractFunctions(self.abi, self.tron, self.address)
        self.fallback = Contract.get_fallback_function(self.abi, self.tron, self.address)

    @classmethod
    def factory(cls, tron: any, class_name=None, **kwargs) -&gt; &#34;PropertyCheckingFactory&#34;:

        kwargs[&#39;tron&#39;] = tron
        normalizers = {
            &#39;abi&#39;: normalize_abi,
            &#39;bytecode&#39;: normalize_bytecode,
            &#39;bytecode_runtime&#39;: normalize_bytecode,
        }

        contract = PropertyCheckingFactory(
            class_name or cls.__name__,
            (cls,),
            kwargs,
            normalizers=normalizers
        )

        setattr(contract, &#39;functions&#39;, ContractFunctions(contract.abi, contract.tron))
        setattr(contract, &#39;fallback&#39;, Contract.get_fallback_function(contract.abi, contract.tron))

        return contract

    @classmethod
    @deprecated_for(&#34;contract.constructor.transact&#34;)
    def deploy(cls, **kwargs):
        &#34;&#34;&#34;Deploy Contract

        This method can also be done in &#34;contract.constructor.transact&#34;

        Deploys a contract.
        Returns TransactionExtention, which contains an unsigned transaction.

        Example:
        .. code-block:: python
            &gt;&gt;&gt; MyContract.deploy(
                fee_limit=10**9,
                call_value=0,
                consume_user_resource_percent=10
            )

        Args:
            **kwargs: Transaction parameters for the deployment
            transaction as a dict

        &#34;&#34;&#34;

        return cls.tron.transaction_builder.create_smart_contract(
            **kwargs,
            abi=cls.abi,
            bytecode=to_hex(cls.bytecode)
        )

    @classmethod
    def constructor(cls) -&gt; any:
        if cls.bytecode is None:
            raise ValueError(
                &#34;Cannot call constructor on a contract that does not have &#39;bytecode&#39; associated &#34;
                &#34;with it&#34;
            )
        return ContractConstructor(cls.tron,
                                   cls.abi,
                                   cls.bytecode)

    @combomethod
    def encodeABI(cls, fn_name, args=None, kwargs=None, data=None) -&gt; Union[HexStr, str]:
        &#34;&#34;&#34;Encodes the arguments using the Tron ABI for the contract function
        that matches the given name and arguments..
        &#34;&#34;&#34;
        fn_abi, fn_selector, fn_arguments = get_function_info(
            fn_name, contract_abi=cls.abi, args=args, kwargs=kwargs,
        )

        if data is None:
            data = fn_selector

        return encode_abi(cls.tron, fn_abi, fn_arguments, data)

    @staticmethod
    def get_fallback_function(abi, tron, address=None) -&gt; any:
        if abi and fallback_func_abi_exists(abi):
            return ContractFunction.factory(
                &#39;fallback&#39;,
                tron=tron,
                contract_abi=abi,
                address=address,
                function_identifier=FallbackFn)()

        return NonExistentFallbackFunction()

    @combomethod
    def all_functions(self) -&gt; list:
        return find_functions_by_identifier(
            self.abi, self.tron, self.address, lambda _: True
        )

    @combomethod
    def get_function_by_signature(self, signature) -&gt; list:
        if &#39; &#39; in signature:
            raise ValueError(
                &#39;Function signature should not contain any spaces. &#39;
                &#39;Found spaces in input: %s&#39; % signature
            )

        def callable_check(fn_abi):
            return abi_to_signature(fn_abi) == signature

        fns = find_functions_by_identifier(self.abi, self.tron, self.address, callable_check)
        return get_function_by_identifier(fns, &#39;signature&#39;)

    @combomethod
    def find_functions_by_name(self, fn_name) -&gt; list:
        def callable_check(fn_abi):
            return fn_abi[&#39;name&#39;] == fn_name

        return find_functions_by_identifier(
            self.abi, self.tron, self.address, callable_check
        )

    @combomethod
    def get_function_by_name(self, fn_name) -&gt; any:
        fns = self.find_functions_by_name(fn_name)
        return get_function_by_identifier(fns, &#39;name&#39;)

    @combomethod
    def get_function_by_selector(self, selector):
        def callable_check(fn_abi) -&gt; bool:
            return encode_hex(function_abi_to_4byte_selector(fn_abi)) == to_4byte_hex(selector)

        fns = find_functions_by_identifier(self.abi, self.tron, self.address, callable_check)
        return get_function_by_identifier(fns, &#39;selector&#39;)

    @combomethod
    def decode_function_input(self, data) -&gt; Tuple[any, dict]:
        data = HexBytes(data)
        selector, params = data[:4], data[4:]
        func = self.get_function_by_selector(selector)
        names = [x[&#39;name&#39;] for x in func.abi[&#39;inputs&#39;]]
        types = [x[&#39;type&#39;] for x in func.abi[&#39;inputs&#39;]]
        decoded = decode_abi(types, params)
        normalized = map_abi_data(BASE_RETURN_NORMALIZERS, types, decoded)
        return func, dict(zip(names, normalized))

    @combomethod
    def find_functions_by_args(self, *args) -&gt; list:
        def callable_check(fn_abi) -&gt; bool:
            return check_if_arguments_can_be_encoded(fn_abi, args=args, kwargs={})

        return find_functions_by_identifier(
            self.abi, self.tron, self.address, callable_check
        )

    @combomethod
    def get_function_by_args(self, *args):
        fns = self.find_functions_by_args(*args)
        return get_function_by_identifier(fns, &#39;args&#39;)


class ContractConstructor:
    &#34;&#34;&#34;
    Class for contract constructor API.
    &#34;&#34;&#34;

    def __init__(self, tron, abi, bytecode):
        self.tron = tron
        self.abi = abi
        self.bytecode = bytecode

    @staticmethod
    def check_forbidden_keys_in_transaction(transaction, forbidden_keys=None):
        keys_found = set(transaction.keys()) &amp; set(forbidden_keys)
        if keys_found:
            raise ValueError(&#34;Cannot set {} in transaction&#34;.format(&#39;, &#39;.join(keys_found)))

    @combomethod
    def transact(self, **kwargs):
        &#34;&#34;&#34;Deploy Contract

        Deploys a contract.
        Returns TransactionExtention, which contains an unsigned transaction.

        Args:
            **kwargs: Additional options to send
        &#34;&#34;&#34;

        return self.tron.transaction_builder.create_smart_contract(
            **kwargs,
            abi=self.abi,
            bytecode=to_hex(self.bytecode)
        )


def find_functions_by_identifier(contract_abi, tron, address, callable_check) -&gt; list:
    fns_abi = filter_by_type(&#39;function&#39;, contract_abi)
    return [
        ContractFunction.factory(
            fn_abi[&#39;name&#39;],
            tron=tron,
            contract_abi=contract_abi,
            address=address,
            function_identifier=fn_abi[&#39;name&#39;],
            abi=fn_abi
        )
        for fn_abi in fns_abi
        if callable_check(fn_abi)
    ]


def get_function_by_identifier(fns, identifier):
    if len(fns) &gt; 1:
        raise ValueError(
            &#39;Found multiple functions with matching {0}. &#39;
            &#39;Found: {1!r}&#39;.format(identifier, fns)
        )
    elif len(fns) == 0:
        raise ValueError(
            &#39;Could not find any function with matching {0}&#39;.format(identifier)
        )
    return fns[0]


def printdebugfunc(typecontrol, func):
    b = &#34;{} {}({}) {}&#34;
    input_space = &#34;&#34;
    oput_space = &#34;&#34;

    try:
        input_space = func[&#39;input&#39;]
    except KeyError:
        pass

    try:
        oput_space = &#34;-&gt; {}&#34;.format(func[&#39;output&#39;])
    except KeyError:
        pass

    print(b.format(typecontrol, func[&#39;name&#39;], input_space, oput_space))
    print(&#34;=====&#34;)</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="tronpytool.contract.find_functions_by_identifier"><code class="name flex">
<span>def <span class="ident">find_functions_by_identifier</span></span>(<span>contract_abi, tron, address, callable_check) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def find_functions_by_identifier(contract_abi, tron, address, callable_check) -&gt; list:
    fns_abi = filter_by_type(&#39;function&#39;, contract_abi)
    return [
        ContractFunction.factory(
            fn_abi[&#39;name&#39;],
            tron=tron,
            contract_abi=contract_abi,
            address=address,
            function_identifier=fn_abi[&#39;name&#39;],
            abi=fn_abi
        )
        for fn_abi in fns_abi
        if callable_check(fn_abi)
    ]</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.get_function_by_identifier"><code class="name flex">
<span>def <span class="ident">get_function_by_identifier</span></span>(<span>fns, identifier)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_function_by_identifier(fns, identifier):
    if len(fns) &gt; 1:
        raise ValueError(
            &#39;Found multiple functions with matching {0}. &#39;
            &#39;Found: {1!r}&#39;.format(identifier, fns)
        )
    elif len(fns) == 0:
        raise ValueError(
            &#39;Could not find any function with matching {0}&#39;.format(identifier)
        )
    return fns[0]</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.printdebugfunc"><code class="name flex">
<span>def <span class="ident">printdebugfunc</span></span>(<span>typecontrol, func)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def printdebugfunc(typecontrol, func):
    b = &#34;{} {}({}) {}&#34;
    input_space = &#34;&#34;
    oput_space = &#34;&#34;

    try:
        input_space = func[&#39;input&#39;]
    except KeyError:
        pass

    try:
        oput_space = &#34;-&gt; {}&#34;.format(func[&#39;output&#39;])
    except KeyError:
        pass

    print(b.format(typecontrol, func[&#39;name&#39;], input_space, oput_space))
    print(&#34;=====&#34;)</code></pre>
</details>
</dd>
</dl>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="tronpytool.contract.Contract"><code class="flex name class">
<span>class <span class="ident">Contract</span></span>
<span>(</span><span>address=None)</span>
</code></dt>
<dd>
<div class="desc"><p>Create a new smart contract proxy object.
:param address: Contract address as 0x hex string</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class Contract:
    # set during class construction
    tron = None

    # instance level properties
    address = None

    # class properties (overridable at instance level)
    abi = None

    bytecode = None
    bytecode_runtime = None

    functions = None
    events = None
    fallback = None

    def __init__(self, address=None):
        &#34;&#34;&#34;Create a new smart contract proxy object.
        :param address: Contract address as 0x hex string
        &#34;&#34;&#34;
        if self.tron is None:
            raise AttributeError(
                &#39;The `Contract` class has not been initialized.  Please use the &#39;
                &#39;`tron.contract` interface to create your contract class.&#39;
            )

        if address:
            self.address = self.tron.address.to_hex(address)

        if not self.address:
            raise TypeError(&#34;The address argument is required to instantiate a contract.&#34;)

        self.functions = ContractFunctions(self.abi, self.tron, self.address)
        self.fallback = Contract.get_fallback_function(self.abi, self.tron, self.address)

    @classmethod
    def factory(cls, tron: any, class_name=None, **kwargs) -&gt; &#34;PropertyCheckingFactory&#34;:

        kwargs[&#39;tron&#39;] = tron
        normalizers = {
            &#39;abi&#39;: normalize_abi,
            &#39;bytecode&#39;: normalize_bytecode,
            &#39;bytecode_runtime&#39;: normalize_bytecode,
        }

        contract = PropertyCheckingFactory(
            class_name or cls.__name__,
            (cls,),
            kwargs,
            normalizers=normalizers
        )

        setattr(contract, &#39;functions&#39;, ContractFunctions(contract.abi, contract.tron))
        setattr(contract, &#39;fallback&#39;, Contract.get_fallback_function(contract.abi, contract.tron))

        return contract

    @classmethod
    @deprecated_for(&#34;contract.constructor.transact&#34;)
    def deploy(cls, **kwargs):
        &#34;&#34;&#34;Deploy Contract

        This method can also be done in &#34;contract.constructor.transact&#34;

        Deploys a contract.
        Returns TransactionExtention, which contains an unsigned transaction.

        Example:
        .. code-block:: python
            &gt;&gt;&gt; MyContract.deploy(
                fee_limit=10**9,
                call_value=0,
                consume_user_resource_percent=10
            )

        Args:
            **kwargs: Transaction parameters for the deployment
            transaction as a dict

        &#34;&#34;&#34;

        return cls.tron.transaction_builder.create_smart_contract(
            **kwargs,
            abi=cls.abi,
            bytecode=to_hex(cls.bytecode)
        )

    @classmethod
    def constructor(cls) -&gt; any:
        if cls.bytecode is None:
            raise ValueError(
                &#34;Cannot call constructor on a contract that does not have &#39;bytecode&#39; associated &#34;
                &#34;with it&#34;
            )
        return ContractConstructor(cls.tron,
                                   cls.abi,
                                   cls.bytecode)

    @combomethod
    def encodeABI(cls, fn_name, args=None, kwargs=None, data=None) -&gt; Union[HexStr, str]:
        &#34;&#34;&#34;Encodes the arguments using the Tron ABI for the contract function
        that matches the given name and arguments..
        &#34;&#34;&#34;
        fn_abi, fn_selector, fn_arguments = get_function_info(
            fn_name, contract_abi=cls.abi, args=args, kwargs=kwargs,
        )

        if data is None:
            data = fn_selector

        return encode_abi(cls.tron, fn_abi, fn_arguments, data)

    @staticmethod
    def get_fallback_function(abi, tron, address=None) -&gt; any:
        if abi and fallback_func_abi_exists(abi):
            return ContractFunction.factory(
                &#39;fallback&#39;,
                tron=tron,
                contract_abi=abi,
                address=address,
                function_identifier=FallbackFn)()

        return NonExistentFallbackFunction()

    @combomethod
    def all_functions(self) -&gt; list:
        return find_functions_by_identifier(
            self.abi, self.tron, self.address, lambda _: True
        )

    @combomethod
    def get_function_by_signature(self, signature) -&gt; list:
        if &#39; &#39; in signature:
            raise ValueError(
                &#39;Function signature should not contain any spaces. &#39;
                &#39;Found spaces in input: %s&#39; % signature
            )

        def callable_check(fn_abi):
            return abi_to_signature(fn_abi) == signature

        fns = find_functions_by_identifier(self.abi, self.tron, self.address, callable_check)
        return get_function_by_identifier(fns, &#39;signature&#39;)

    @combomethod
    def find_functions_by_name(self, fn_name) -&gt; list:
        def callable_check(fn_abi):
            return fn_abi[&#39;name&#39;] == fn_name

        return find_functions_by_identifier(
            self.abi, self.tron, self.address, callable_check
        )

    @combomethod
    def get_function_by_name(self, fn_name) -&gt; any:
        fns = self.find_functions_by_name(fn_name)
        return get_function_by_identifier(fns, &#39;name&#39;)

    @combomethod
    def get_function_by_selector(self, selector):
        def callable_check(fn_abi) -&gt; bool:
            return encode_hex(function_abi_to_4byte_selector(fn_abi)) == to_4byte_hex(selector)

        fns = find_functions_by_identifier(self.abi, self.tron, self.address, callable_check)
        return get_function_by_identifier(fns, &#39;selector&#39;)

    @combomethod
    def decode_function_input(self, data) -&gt; Tuple[any, dict]:
        data = HexBytes(data)
        selector, params = data[:4], data[4:]
        func = self.get_function_by_selector(selector)
        names = [x[&#39;name&#39;] for x in func.abi[&#39;inputs&#39;]]
        types = [x[&#39;type&#39;] for x in func.abi[&#39;inputs&#39;]]
        decoded = decode_abi(types, params)
        normalized = map_abi_data(BASE_RETURN_NORMALIZERS, types, decoded)
        return func, dict(zip(names, normalized))

    @combomethod
    def find_functions_by_args(self, *args) -&gt; list:
        def callable_check(fn_abi) -&gt; bool:
            return check_if_arguments_can_be_encoded(fn_abi, args=args, kwargs={})

        return find_functions_by_identifier(
            self.abi, self.tron, self.address, callable_check
        )

    @combomethod
    def get_function_by_args(self, *args):
        fns = self.find_functions_by_args(*args)
        return get_function_by_identifier(fns, &#39;args&#39;)</code></pre>
</details>
<h3>Class variables</h3>
<dl>
<dt id="tronpytool.contract.Contract.abi"><code class="name">var <span class="ident">abi</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.Contract.address"><code class="name">var <span class="ident">address</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.Contract.bytecode"><code class="name">var <span class="ident">bytecode</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.Contract.bytecode_runtime"><code class="name">var <span class="ident">bytecode_runtime</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.Contract.events"><code class="name">var <span class="ident">events</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.Contract.fallback"><code class="name">var <span class="ident">fallback</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.Contract.functions"><code class="name">var <span class="ident">functions</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.Contract.tron"><code class="name">var <span class="ident">tron</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="tronpytool.contract.Contract.constructor"><code class="name flex">
<span>def <span class="ident">constructor</span></span>(<span>) ‑> <built-in function any></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def constructor(cls) -&gt; any:
    if cls.bytecode is None:
        raise ValueError(
            &#34;Cannot call constructor on a contract that does not have &#39;bytecode&#39; associated &#34;
            &#34;with it&#34;
        )
    return ContractConstructor(cls.tron,
                               cls.abi,
                               cls.bytecode)</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.deploy"><code class="name flex">
<span>def <span class="ident">deploy</span></span>(<span>cls, **kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>Deploy Contract</p>
<p>This method can also be done in "contract.constructor.transact"</p>
<p>Deploys a contract.
Returns TransactionExtention, which contains an unsigned transaction.</p>
<p>Example:
.. code-block:: python
&gt;&gt;&gt; MyContract.deploy(
fee_limit=10**9,
call_value=0,
consume_user_resource_percent=10
)</p>
<h2 id="args">Args</h2>
<dl>
<dt><strong><code>**kwargs</code></strong></dt>
<dd>Transaction parameters for the deployment</dd>
</dl>
<p>transaction as a dict</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
@deprecated_for(&#34;contract.constructor.transact&#34;)
def deploy(cls, **kwargs):
    &#34;&#34;&#34;Deploy Contract

    This method can also be done in &#34;contract.constructor.transact&#34;

    Deploys a contract.
    Returns TransactionExtention, which contains an unsigned transaction.

    Example:
    .. code-block:: python
        &gt;&gt;&gt; MyContract.deploy(
            fee_limit=10**9,
            call_value=0,
            consume_user_resource_percent=10
        )

    Args:
        **kwargs: Transaction parameters for the deployment
        transaction as a dict

    &#34;&#34;&#34;

    return cls.tron.transaction_builder.create_smart_contract(
        **kwargs,
        abi=cls.abi,
        bytecode=to_hex(cls.bytecode)
    )</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.factory"><code class="name flex">
<span>def <span class="ident">factory</span></span>(<span>tron: <built-in function any>, class_name=None, **kwargs) ‑> <a title="tronpytool.common.datatypes.PropertyCheckingFactory" href="common/datatypes.html#tronpytool.common.datatypes.PropertyCheckingFactory">PropertyCheckingFactory</a></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def factory(cls, tron: any, class_name=None, **kwargs) -&gt; &#34;PropertyCheckingFactory&#34;:

    kwargs[&#39;tron&#39;] = tron
    normalizers = {
        &#39;abi&#39;: normalize_abi,
        &#39;bytecode&#39;: normalize_bytecode,
        &#39;bytecode_runtime&#39;: normalize_bytecode,
    }

    contract = PropertyCheckingFactory(
        class_name or cls.__name__,
        (cls,),
        kwargs,
        normalizers=normalizers
    )

    setattr(contract, &#39;functions&#39;, ContractFunctions(contract.abi, contract.tron))
    setattr(contract, &#39;fallback&#39;, Contract.get_fallback_function(contract.abi, contract.tron))

    return contract</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.get_fallback_function"><code class="name flex">
<span>def <span class="ident">get_fallback_function</span></span>(<span>abi, tron, address=None) ‑> <built-in function any></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def get_fallback_function(abi, tron, address=None) -&gt; any:
    if abi and fallback_func_abi_exists(abi):
        return ContractFunction.factory(
            &#39;fallback&#39;,
            tron=tron,
            contract_abi=abi,
            address=address,
            function_identifier=FallbackFn)()

    return NonExistentFallbackFunction()</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="tronpytool.contract.Contract.all_functions"><code class="name flex">
<span>def <span class="ident">all_functions</span></span>(<span>self) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def all_functions(self) -&gt; list:
    return find_functions_by_identifier(
        self.abi, self.tron, self.address, lambda _: True
    )</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.decode_function_input"><code class="name flex">
<span>def <span class="ident">decode_function_input</span></span>(<span>self, data) ‑> Tuple[<built-in function any>, dict]</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def decode_function_input(self, data) -&gt; Tuple[any, dict]:
    data = HexBytes(data)
    selector, params = data[:4], data[4:]
    func = self.get_function_by_selector(selector)
    names = [x[&#39;name&#39;] for x in func.abi[&#39;inputs&#39;]]
    types = [x[&#39;type&#39;] for x in func.abi[&#39;inputs&#39;]]
    decoded = decode_abi(types, params)
    normalized = map_abi_data(BASE_RETURN_NORMALIZERS, types, decoded)
    return func, dict(zip(names, normalized))</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.encodeABI"><code class="name flex">
<span>def <span class="ident">encodeABI</span></span>(<span>cls, fn_name, args=None, kwargs=None, data=None) ‑> Union[HexStr, str]</span>
</code></dt>
<dd>
<div class="desc"><p>Encodes the arguments using the Tron ABI for the contract function
that matches the given name and arguments..</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def encodeABI(cls, fn_name, args=None, kwargs=None, data=None) -&gt; Union[HexStr, str]:
    &#34;&#34;&#34;Encodes the arguments using the Tron ABI for the contract function
    that matches the given name and arguments..
    &#34;&#34;&#34;
    fn_abi, fn_selector, fn_arguments = get_function_info(
        fn_name, contract_abi=cls.abi, args=args, kwargs=kwargs,
    )

    if data is None:
        data = fn_selector

    return encode_abi(cls.tron, fn_abi, fn_arguments, data)</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.find_functions_by_args"><code class="name flex">
<span>def <span class="ident">find_functions_by_args</span></span>(<span>self, *args) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def find_functions_by_args(self, *args) -&gt; list:
    def callable_check(fn_abi) -&gt; bool:
        return check_if_arguments_can_be_encoded(fn_abi, args=args, kwargs={})

    return find_functions_by_identifier(
        self.abi, self.tron, self.address, callable_check
    )</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.find_functions_by_name"><code class="name flex">
<span>def <span class="ident">find_functions_by_name</span></span>(<span>self, fn_name) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def find_functions_by_name(self, fn_name) -&gt; list:
    def callable_check(fn_abi):
        return fn_abi[&#39;name&#39;] == fn_name

    return find_functions_by_identifier(
        self.abi, self.tron, self.address, callable_check
    )</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.get_function_by_args"><code class="name flex">
<span>def <span class="ident">get_function_by_args</span></span>(<span>self, *args)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def get_function_by_args(self, *args):
    fns = self.find_functions_by_args(*args)
    return get_function_by_identifier(fns, &#39;args&#39;)</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.get_function_by_name"><code class="name flex">
<span>def <span class="ident">get_function_by_name</span></span>(<span>self, fn_name) ‑> <built-in function any></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def get_function_by_name(self, fn_name) -&gt; any:
    fns = self.find_functions_by_name(fn_name)
    return get_function_by_identifier(fns, &#39;name&#39;)</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.get_function_by_selector"><code class="name flex">
<span>def <span class="ident">get_function_by_selector</span></span>(<span>self, selector)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def get_function_by_selector(self, selector):
    def callable_check(fn_abi) -&gt; bool:
        return encode_hex(function_abi_to_4byte_selector(fn_abi)) == to_4byte_hex(selector)

    fns = find_functions_by_identifier(self.abi, self.tron, self.address, callable_check)
    return get_function_by_identifier(fns, &#39;selector&#39;)</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.Contract.get_function_by_signature"><code class="name flex">
<span>def <span class="ident">get_function_by_signature</span></span>(<span>self, signature) ‑> list</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def get_function_by_signature(self, signature) -&gt; list:
    if &#39; &#39; in signature:
        raise ValueError(
            &#39;Function signature should not contain any spaces. &#39;
            &#39;Found spaces in input: %s&#39; % signature
        )

    def callable_check(fn_abi):
        return abi_to_signature(fn_abi) == signature

    fns = find_functions_by_identifier(self.abi, self.tron, self.address, callable_check)
    return get_function_by_identifier(fns, &#39;signature&#39;)</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="tronpytool.contract.ContractConstructor"><code class="flex name class">
<span>class <span class="ident">ContractConstructor</span></span>
<span>(</span><span>tron, abi, bytecode)</span>
</code></dt>
<dd>
<div class="desc"><p>Class for contract constructor API.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class ContractConstructor:
    &#34;&#34;&#34;
    Class for contract constructor API.
    &#34;&#34;&#34;

    def __init__(self, tron, abi, bytecode):
        self.tron = tron
        self.abi = abi
        self.bytecode = bytecode

    @staticmethod
    def check_forbidden_keys_in_transaction(transaction, forbidden_keys=None):
        keys_found = set(transaction.keys()) &amp; set(forbidden_keys)
        if keys_found:
            raise ValueError(&#34;Cannot set {} in transaction&#34;.format(&#39;, &#39;.join(keys_found)))

    @combomethod
    def transact(self, **kwargs):
        &#34;&#34;&#34;Deploy Contract

        Deploys a contract.
        Returns TransactionExtention, which contains an unsigned transaction.

        Args:
            **kwargs: Additional options to send
        &#34;&#34;&#34;

        return self.tron.transaction_builder.create_smart_contract(
            **kwargs,
            abi=self.abi,
            bytecode=to_hex(self.bytecode)
        )</code></pre>
</details>
<h3>Static methods</h3>
<dl>
<dt id="tronpytool.contract.ContractConstructor.check_forbidden_keys_in_transaction"><code class="name flex">
<span>def <span class="ident">check_forbidden_keys_in_transaction</span></span>(<span>transaction, forbidden_keys=None)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def check_forbidden_keys_in_transaction(transaction, forbidden_keys=None):
    keys_found = set(transaction.keys()) &amp; set(forbidden_keys)
    if keys_found:
        raise ValueError(&#34;Cannot set {} in transaction&#34;.format(&#39;, &#39;.join(keys_found)))</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="tronpytool.contract.ContractConstructor.transact"><code class="name flex">
<span>def <span class="ident">transact</span></span>(<span>self, **kwargs)</span>
</code></dt>
<dd>
<div class="desc"><p>Deploy Contract</p>
<p>Deploys a contract.
Returns TransactionExtention, which contains an unsigned transaction.</p>
<h2 id="args">Args</h2>
<dl>
<dt><strong><code>**kwargs</code></strong></dt>
<dd>Additional options to send</dd>
</dl></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@combomethod
def transact(self, **kwargs):
    &#34;&#34;&#34;Deploy Contract

    Deploys a contract.
    Returns TransactionExtention, which contains an unsigned transaction.

    Args:
        **kwargs: Additional options to send
    &#34;&#34;&#34;

    return self.tron.transaction_builder.create_smart_contract(
        **kwargs,
        abi=self.abi,
        bytecode=to_hex(self.bytecode)
    )</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="tronpytool.contract.ContractFunction"><code class="flex name class">
<span>class <span class="ident">ContractFunction</span></span>
<span>(</span><span>abi=None)</span>
</code></dt>
<dd>
<div class="desc"><p>Base class for contract functions</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class ContractFunction:
    &#34;&#34;&#34;Base class for contract functions&#34;&#34;&#34;
    address = None
    function_identifier = None
    tron = None
    contract_abi = None
    abi = None
    transaction = None
    arguments = None

    def __init__(self, abi=None):
        self.abi = abi
        self.fn_name = type(self).__name__

    def __call__(self, *args, **kwargs):
        clone = copy.copy(self)
        if args is None:
            clone.args = tuple()
        else:
            clone.args = args

        if kwargs is None:
            clone.kwargs = {}
        else:
            clone.kwargs = kwargs
        clone._set_function_info()
        return clone

    def _set_function_info(self):
        if not self.abi:
            self.abi = find_matching_fn_abi(
                self.contract_abi,
                self.function_identifier,
                self.args,
                self.kwargs
            )
        if self.function_identifier is FallbackFn:
            self.selector = encode_hex(b&#39;&#39;)
        elif is_text(self.function_identifier):
            self.selector = encode_hex(function_abi_to_4byte_selector(self.abi))
        else:
            raise TypeError(&#34;Unsupported function identifier&#34;)

        self.arguments = merge_args_and_kwargs(self.abi, self.args, self.kwargs)

    @classmethod
    def factory(cls, class_name, **kwargs):
        return PropertyCheckingFactory(class_name, (cls,), kwargs)(kwargs.get(&#39;abi&#39;))

    def __repr__(self):
        if self.abi:
            _repr = &#39;&lt;Function %s&#39; % abi_to_signature(self.abi)
            if self.arguments is not None:
                _repr += &#39; bound to %r&#39; % (self.arguments,)
            return _repr + &#39;&gt;&#39;
        return &#39;&lt;Function %s&gt;&#39; % self.fn_name</code></pre>
</details>
<h3>Class variables</h3>
<dl>
<dt id="tronpytool.contract.ContractFunction.abi"><code class="name">var <span class="ident">abi</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.ContractFunction.address"><code class="name">var <span class="ident">address</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.ContractFunction.arguments"><code class="name">var <span class="ident">arguments</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.ContractFunction.contract_abi"><code class="name">var <span class="ident">contract_abi</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.ContractFunction.function_identifier"><code class="name">var <span class="ident">function_identifier</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.ContractFunction.transaction"><code class="name">var <span class="ident">transaction</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="tronpytool.contract.ContractFunction.tron"><code class="name">var <span class="ident">tron</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="tronpytool.contract.ContractFunction.factory"><code class="name flex">
<span>def <span class="ident">factory</span></span>(<span>class_name, **kwargs)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def factory(cls, class_name, **kwargs):
    return PropertyCheckingFactory(class_name, (cls,), kwargs)(kwargs.get(&#39;abi&#39;))</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="tronpytool.contract.ContractFunctions"><code class="flex name class">
<span>class <span class="ident">ContractFunctions</span></span>
<span>(</span><span>_abi, tron, address=None)</span>
</code></dt>
<dd>
<div class="desc"><p>Class containing contract function objects</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class ContractFunctions:
    &#34;&#34;&#34;
    Class containing contract function objects
    &#34;&#34;&#34;

    def __init__(self, _abi, tron, address=None):
        if _abi:
            self._functions = filter_by_type(&#39;function&#39;, _abi)
            for func in self._functions:
                setattr(self, func[&#39;name&#39;],
                        ContractFunction.factory(
                            func[&#39;name&#39;],
                            tron=tron,
                            contract_abi=_abi,
                            address=address,
                            function_identifier=func[&#39;name&#39;]))
            self.abi = _abi

    def get_abi_by_name(self, func_name: str) -&gt; dict:
        &#34;&#34;&#34;Find the correct function abi for the name&#34;&#34;&#34;
        t = filter_by_name(func_name, self.abi)
        if len(t) &gt; 0:
            return t[0]
        raise NoABIFunctionsFound(
            &#34;The abi for this contract contains no function definitions. &#34;,
            &#34;Are you sure you provided the correct call name from the abi?&#34;
        )

    def print_functions(self):
        &#34;&#34;&#34;only for testing, list all the functions that can be called. &#34;&#34;&#34;
        for func in self._functions:
            if func[&#39;type&#39;] == &#39;function&#39;:
                if func[&#39;stateMutability&#39;] in [&#39;pure&#39;, &#39;view&#39;]:
                    printdebugfunc(&#39;read&#39;, func)
                if func[&#39;stateMutability&#39;] in [&#39;nonpayable&#39;]:
                    printdebugfunc(&#39;write&#39;, func)

            if func[&#39;type&#39;] == &#39;constructor&#39;:
                printdebugfunc(&#39;constructor&#39;, func)
            print(&#34;=====&#34;)
            print(func)

    def __iter__(self):
        if not hasattr(self, &#39;_functions&#39;) or not self._functions:
            return

        for func in self._functions:
            yield func[&#39;name&#39;]

    def __getattr__(self, function_name):
        if &#39;_functions&#39; not in self.__dict__:
            raise NoABIFunctionsFound(
                &#34;The abi for this contract contains no function definitions. &#34;,
                &#34;Are you sure you provided the correct contract abi?&#34;
            )
        elif function_name not in self.__dict__[&#39;_functions&#39;]:
            raise MismatchedABI(
                &#34;The function &#39;{}&#39; was not found in this contract&#39;s abi. &#34;.format(function_name),
                &#34;Are you sure you provided the correct contract abi?&#34;
            )
        else:
            return super().__getattribute__(function_name)

    def __getitem__(self, function_name):
        return getattr(self, function_name)</code></pre>
</details>
<h3>Methods</h3>
<dl>
<dt id="tronpytool.contract.ContractFunctions.get_abi_by_name"><code class="name flex">
<span>def <span class="ident">get_abi_by_name</span></span>(<span>self, func_name: str) ‑> dict</span>
</code></dt>
<dd>
<div class="desc"><p>Find the correct function abi for the name</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_abi_by_name(self, func_name: str) -&gt; dict:
    &#34;&#34;&#34;Find the correct function abi for the name&#34;&#34;&#34;
    t = filter_by_name(func_name, self.abi)
    if len(t) &gt; 0:
        return t[0]
    raise NoABIFunctionsFound(
        &#34;The abi for this contract contains no function definitions. &#34;,
        &#34;Are you sure you provided the correct call name from the abi?&#34;
    )</code></pre>
</details>
</dd>
<dt id="tronpytool.contract.ContractFunctions.print_functions"><code class="name flex">
<span>def <span class="ident">print_functions</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>only for testing, list all the functions that can be called.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def print_functions(self):
    &#34;&#34;&#34;only for testing, list all the functions that can be called. &#34;&#34;&#34;
    for func in self._functions:
        if func[&#39;type&#39;] == &#39;function&#39;:
            if func[&#39;stateMutability&#39;] in [&#39;pure&#39;, &#39;view&#39;]:
                printdebugfunc(&#39;read&#39;, func)
            if func[&#39;stateMutability&#39;] in [&#39;nonpayable&#39;]:
                printdebugfunc(&#39;write&#39;, func)

        if func[&#39;type&#39;] == &#39;constructor&#39;:
            printdebugfunc(&#39;constructor&#39;, func)
        print(&#34;=====&#34;)
        print(func)</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="tronpytool.contract.NonExistentFallbackFunction"><code class="flex name class">
<span>class <span class="ident">NonExistentFallbackFunction</span></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class NonExistentFallbackFunction:
    @staticmethod
    def _raise_exception():
        raise FallbackNotFound(&#34;No fallback function was found in the contract ABI.&#34;)

    def __getattr__(self, attr):
        return NonExistentFallbackFunction._raise_exception</code></pre>
</details>
</dd>
</dl>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="tronpytool" href="index.html">tronpytool</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="tronpytool.contract.find_functions_by_identifier" href="#tronpytool.contract.find_functions_by_identifier">find_functions_by_identifier</a></code></li>
<li><code><a title="tronpytool.contract.get_function_by_identifier" href="#tronpytool.contract.get_function_by_identifier">get_function_by_identifier</a></code></li>
<li><code><a title="tronpytool.contract.printdebugfunc" href="#tronpytool.contract.printdebugfunc">printdebugfunc</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
<ul>
<li>
<h4><code><a title="tronpytool.contract.Contract" href="#tronpytool.contract.Contract">Contract</a></code></h4>
<ul class="">
<li><code><a title="tronpytool.contract.Contract.abi" href="#tronpytool.contract.Contract.abi">abi</a></code></li>
<li><code><a title="tronpytool.contract.Contract.address" href="#tronpytool.contract.Contract.address">address</a></code></li>
<li><code><a title="tronpytool.contract.Contract.all_functions" href="#tronpytool.contract.Contract.all_functions">all_functions</a></code></li>
<li><code><a title="tronpytool.contract.Contract.bytecode" href="#tronpytool.contract.Contract.bytecode">bytecode</a></code></li>
<li><code><a title="tronpytool.contract.Contract.bytecode_runtime" href="#tronpytool.contract.Contract.bytecode_runtime">bytecode_runtime</a></code></li>
<li><code><a title="tronpytool.contract.Contract.constructor" href="#tronpytool.contract.Contract.constructor">constructor</a></code></li>
<li><code><a title="tronpytool.contract.Contract.decode_function_input" href="#tronpytool.contract.Contract.decode_function_input">decode_function_input</a></code></li>
<li><code><a title="tronpytool.contract.Contract.deploy" href="#tronpytool.contract.Contract.deploy">deploy</a></code></li>
<li><code><a title="tronpytool.contract.Contract.encodeABI" href="#tronpytool.contract.Contract.encodeABI">encodeABI</a></code></li>
<li><code><a title="tronpytool.contract.Contract.events" href="#tronpytool.contract.Contract.events">events</a></code></li>
<li><code><a title="tronpytool.contract.Contract.factory" href="#tronpytool.contract.Contract.factory">factory</a></code></li>
<li><code><a title="tronpytool.contract.Contract.fallback" href="#tronpytool.contract.Contract.fallback">fallback</a></code></li>
<li><code><a title="tronpytool.contract.Contract.find_functions_by_args" href="#tronpytool.contract.Contract.find_functions_by_args">find_functions_by_args</a></code></li>
<li><code><a title="tronpytool.contract.Contract.find_functions_by_name" href="#tronpytool.contract.Contract.find_functions_by_name">find_functions_by_name</a></code></li>
<li><code><a title="tronpytool.contract.Contract.functions" href="#tronpytool.contract.Contract.functions">functions</a></code></li>
<li><code><a title="tronpytool.contract.Contract.get_fallback_function" href="#tronpytool.contract.Contract.get_fallback_function">get_fallback_function</a></code></li>
<li><code><a title="tronpytool.contract.Contract.get_function_by_args" href="#tronpytool.contract.Contract.get_function_by_args">get_function_by_args</a></code></li>
<li><code><a title="tronpytool.contract.Contract.get_function_by_name" href="#tronpytool.contract.Contract.get_function_by_name">get_function_by_name</a></code></li>
<li><code><a title="tronpytool.contract.Contract.get_function_by_selector" href="#tronpytool.contract.Contract.get_function_by_selector">get_function_by_selector</a></code></li>
<li><code><a title="tronpytool.contract.Contract.get_function_by_signature" href="#tronpytool.contract.Contract.get_function_by_signature">get_function_by_signature</a></code></li>
<li><code><a title="tronpytool.contract.Contract.tron" href="#tronpytool.contract.Contract.tron">tron</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="tronpytool.contract.ContractConstructor" href="#tronpytool.contract.ContractConstructor">ContractConstructor</a></code></h4>
<ul class="">
<li><code><a title="tronpytool.contract.ContractConstructor.check_forbidden_keys_in_transaction" href="#tronpytool.contract.ContractConstructor.check_forbidden_keys_in_transaction">check_forbidden_keys_in_transaction</a></code></li>
<li><code><a title="tronpytool.contract.ContractConstructor.transact" href="#tronpytool.contract.ContractConstructor.transact">transact</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="tronpytool.contract.ContractFunction" href="#tronpytool.contract.ContractFunction">ContractFunction</a></code></h4>
<ul class="two-column">
<li><code><a title="tronpytool.contract.ContractFunction.abi" href="#tronpytool.contract.ContractFunction.abi">abi</a></code></li>
<li><code><a title="tronpytool.contract.ContractFunction.address" href="#tronpytool.contract.ContractFunction.address">address</a></code></li>
<li><code><a title="tronpytool.contract.ContractFunction.arguments" href="#tronpytool.contract.ContractFunction.arguments">arguments</a></code></li>
<li><code><a title="tronpytool.contract.ContractFunction.contract_abi" href="#tronpytool.contract.ContractFunction.contract_abi">contract_abi</a></code></li>
<li><code><a title="tronpytool.contract.ContractFunction.factory" href="#tronpytool.contract.ContractFunction.factory">factory</a></code></li>
<li><code><a title="tronpytool.contract.ContractFunction.function_identifier" href="#tronpytool.contract.ContractFunction.function_identifier">function_identifier</a></code></li>
<li><code><a title="tronpytool.contract.ContractFunction.transaction" href="#tronpytool.contract.ContractFunction.transaction">transaction</a></code></li>
<li><code><a title="tronpytool.contract.ContractFunction.tron" href="#tronpytool.contract.ContractFunction.tron">tron</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="tronpytool.contract.ContractFunctions" href="#tronpytool.contract.ContractFunctions">ContractFunctions</a></code></h4>
<ul class="">
<li><code><a title="tronpytool.contract.ContractFunctions.get_abi_by_name" href="#tronpytool.contract.ContractFunctions.get_abi_by_name">get_abi_by_name</a></code></li>
<li><code><a title="tronpytool.contract.ContractFunctions.print_functions" href="#tronpytool.contract.ContractFunctions.print_functions">print_functions</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="tronpytool.contract.NonExistentFallbackFunction" href="#tronpytool.contract.NonExistentFallbackFunction">NonExistentFallbackFunction</a></code></h4>
</li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.1</a>.</p>
</footer>
</body>
</html>